package ar.com.cema.methodology.analyzer.ui.servlet.json;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import ar.com.cema.methodology.analyzer.services.MethodologyUsageService;
import ar.com.cema.methodology.analyzer.ui.ServiceLocator;

@WebServlet(name="VariablesJsonProviderServlet", urlPatterns = { ServiceLocator.JSON_VARIABLE_LIST_MP })
public class VariablesJsonProviderServlet extends JsonProviderServlet {
	private static final long serialVersionUID = -4303739437528258567L;

	@Autowired
	private MethodologyUsageService methodologyUsageService;
	
	public void setMethodologyUsageService(MethodologyUsageService methodologyUsageService) {
		this.methodologyUsageService = methodologyUsageService;
	}

	@Override
	protected String getJSON(HttpServletRequest request) {
		return gson.toJson(methodologyUsageService.listVariables());
	}
}